package com.mc.code.service.Impl;

import com.mc.code.entity.CodeItems;
import com.mc.code.entity.ItemStage;
import com.mc.code.entity.Stage;
import com.mc.code.mapper.StageMapper;
import com.mc.code.service.StageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StageImpl implements StageService {

    @Autowired
    private StageMapper stageMapper;

    @Override
    public List<CodeItems> partakeItems(String userNo, int currentPage, int pageCount) {
        return stageMapper.partakeItems(userNo,(currentPage - 1) * pageCount,pageCount);
    }

    @Override
    public void insertItemStage(Integer itemNo, String partakeNo) {
        stageMapper.insertItemStage(itemNo,partakeNo);
    }

//    填入划分以后的阶段详情
    @Override
    public void divideInsertStage(int i,String userNo, int itemNo, int stageNum, String stageName, String stageDate, double stageMoney, String stageExplain) {
            stageMapper.divideInsertStage(i, userNo,itemNo, stageNum, stageName, stageDate, stageMoney, stageExplain);
    }

//    更新参与用户的划分
    @Override
    public void updateStageCondition(int itemNo, String userNo) {
            stageMapper.updateStageCondition(itemNo, userNo);
    }

    @Override
    public int selectStageCondition(Integer itemNo) {
        return stageMapper.selectStageCondition(itemNo) ;
    }

    @Override
    public List<Stage> stageDetail(Integer partakeNo, Integer itemNo) {
        return stageMapper.stageDetail(partakeNo,itemNo);
    }

    @Override
    public List<ItemStage> itemStage(Integer itemNo) {
        return stageMapper.itemStage(itemNo);
    }

    @Override
    public void StageCondition(String userNo, Integer itemNo, Integer stageCondition) {
        stageMapper.StageCondition(userNo,itemNo,stageCondition);
    }

    @Override
    public void stageDetailAgree(Integer itemNo, String partakeNo) {
        stageMapper.stageDetailAgree(itemNo,partakeNo);
    }

    @Override
    public int stageNum(Integer itemNo, String partakeNo) {
        return stageMapper.stageNum(itemNo,partakeNo);
    }

    @Override
    public void stageGeneral(Integer itemNo, String partakeNo, int i) {
        stageMapper.stageGeneral(itemNo, partakeNo, i);
    }

    @Override
    public List<Stage> stageDetailStart(String userNo, Integer itemNo) {
        return stageMapper.stageDetailStart(userNo, itemNo) ;
    }

    @Override
    public int stageCurrent(Integer itemNo, String userNo) {
        return stageMapper.stageCurrent(itemNo,userNo);
    }

    @Override
    public void updateStageCurrent(String partakeNo, Integer stageNum, Integer itemNo) {
        stageMapper.updateStageCurrent(partakeNo, stageNum, itemNo);
    }

    @Override
    public int stageNow(Integer itemNo, String userNo) {
        return  stageMapper.stageNow(itemNo,userNo);
    }

    @Override
    public void uploadStageFile(String filename, Integer itemNo, String partakeNo, Integer stageNum) {
        stageMapper.uploadStageFile(filename,itemNo,partakeNo,stageNum);
    }

    @Override
    public List<ItemStage> itemStartStage(Integer itemNo) {
        return stageMapper.itemStartStage(itemNo);
    }

    @Override
    public String downLoadStageFile(Integer itemNo, String partakeNo, int stageNow) {
        return  stageMapper.downLoadStageFile(itemNo, partakeNo, stageNow);
    }

    @Override
    public void ApplyStageCurrent(Integer itemNo, String partakeNo, Integer checkValue) {
        stageMapper.ApplyStageCurrent(itemNo, partakeNo, checkValue);
    }

    @Override
    public void ApplyStageNow(Integer itemNo, String partakeNo, Integer checkValue) {
        stageMapper.ApplyStageNow(itemNo, partakeNo, checkValue);
    }

    @Override
    public void payPartakeNo(double money, String partakeNo) {
        stageMapper.payPartakeNo(money, partakeNo);
    }

    @Override
    public void finishItem(Integer itemNo) {
        stageMapper.finishItem(itemNo);
    }

    @Override
    public String stageStart(Integer itemNo) {
        return stageMapper.stageStart(itemNo);
    }

    @Override
    public int stageConditiondivision(Integer itemNo, String userNo) {
        return stageMapper.stageConditiondivision(itemNo, userNo) ;
    }

//    回退阶段
    @Override
    public void returnStage(Integer itemNo, String partakeNo, Integer current, Integer now) {
            stageMapper.returnStage(itemNo,partakeNo,current,now);
    }

    @Override
    public int getMyPartakeTotalPage(int pageCount, String userNo) {
        Integer total = stageMapper.getMyPartakeTotalPage(userNo);
        return (total - 1) / pageCount + 1;
    }

}
